# title: 异质性随机前沿模型III——真实随机效应
# author: StableGenius
# date: 2020-02-04
# description: 知乎专栏-科研斗牛犬源代码

# clear workspace
rm(list = ls())

# load packages
library(frontier)

# set work directory
setwd(dirname(parent.frame(2)$ofile))

# load user-defined script
source("core.R")

# load dataset and trans to panel data
data("riceProdPhil")
rawdata <- plm::pdata.frame(riceProdPhil, index = c("FMERCODE", "YEARDUM"))

# specify model
model <- log(PROD) ~ log(AREA) + log(LABOR) + log(NPK)

# estimation
huaji <- sfa_tre(formula = model, data = rawdata)
print(summary(huaji))
